package com.heima.cloud.controller;

import com.heima.cloud.pojo.Order;
import com.heima.cloud.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("order")
public class OrderController {

    @Autowired
    public OrderService orderService;

    @GetMapping("{id}")
    public List<Order> findOrderByUserId(@PathVariable("id")String username){
        if ("itheima".equals(username)) {
            throw new RuntimeException("itheima");
        }
        return orderService.findOrderByUserId(username);
    }
}
